/**
 * @(#)ImageUtils.java, 2010-5-22. 
 * 
 * Copyright 2010 Youdao, Inc. All rights reserved.
 * YOUDAO PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.rsstuan.utils;

import com.google.appengine.api.images.Image;
import com.google.appengine.api.images.ImagesService;
import com.google.appengine.api.images.ImagesServiceFactory;
import com.google.appengine.api.images.Transform;


/**
 *
 * @author guosq
 *
 */
public class ImageUtils {
    private static ImagesService imagesService = ImagesServiceFactory.getImagesService();
    
    private static final int THUMBNAIL_WIDTH = 200;
    
    private static final int THUMBNAIL_HEIGHT = 121;
    
    public static byte[] makeThumbnail(byte[] data) {
       Image oldImage = ImagesServiceFactory.makeImage(data);
       Transform resize = ImagesServiceFactory.makeResize(THUMBNAIL_WIDTH, THUMBNAIL_WIDTH);
       Image newImage = imagesService.applyTransform(resize, oldImage);
       
       return newImage.getImageData();
    }

}
